package com.windgo.controller.admin;

import com.windgo.bean.common.BaseRespVo;
import com.windgo.bean.vo.StatInnerGoods;
import com.windgo.bean.vo.StatInnerOrder;
import com.windgo.bean.vo.StatInnerUser;
import com.windgo.bean.vo.StatVO;
import com.windgo.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

/**
 * @author doublec
 * @since 2022/10/12 20:20
 */

@RestController
@RequestMapping("admin/stat")
public class AdminStatController {
    @Autowired
    AdminService adminService;

    @RequestMapping("user")
    public BaseRespVo<StatVO<StatInnerUser>> statUser(){
        StatVO statVO = new StatVO();
        List<String> list = new LinkedList<>();
        list.add("day");
        list.add("users");
        statVO.setColumns(list);
        List<StatInnerUser> userList = adminService.statUser();
        statVO.setRows(userList);
        return BaseRespVo.ok(statVO);
    }

    @RequestMapping("order")
    public BaseRespVo<StatVO<StatInnerOrder>> statOrder(){
        StatVO statVO = new StatVO();
        List<String> list  = new LinkedList<>();
        //日期
        list.add("day");
        //订单量
        list.add("orders");
        //下单用户数量
        list.add("customers");
        //订单总额
        list.add("amount");
        //客单价（总金额/下单用户数量）
        list.add("pcr");
        statVO.setColumns(list);
        List<StatInnerOrder> orderList = adminService.statOrder();
        statVO.setRows(orderList);
        return BaseRespVo.ok(statVO);
    }

    @RequestMapping("goods")
    public BaseRespVo<StatVO<StatInnerGoods>> statGoods(){
        StatVO statVO = new StatVO();
        List<String> list  = new LinkedList<>();
        //日期
        list.add("day");
        //订单量
        list.add("orders");
        //下单货品数量
        list.add("products");
        //下单货品总额
        list.add("amount");
        statVO.setColumns(list);
        List<StatInnerGoods> goodsList = adminService.statGoods();
        statVO.setRows(goodsList);
        return BaseRespVo.ok(statVO);
    }
}
